<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ include file="../common/header.jsp"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<c:set var="ctx" value="${pageContext.request.contextPath }"></c:set>
<script src="js/jquery-3.5.1.js" type="text/javascript"></script>
<!-- 增加页面开始 -->
<div class="x_content">
    <form class="form-horizontal form-label-left" id="query"
          action="modifyServlet.do?param=modify" method="post" novalidate>
        <span class="section">学生修改页面</span>

        <input type="hidden" name="id" value="${studentInfo.studentId}">
        <input type="hidden" name="namec" value="${namec}">
        <input type="hidden" name="classname" value="${classname}">
        <input type="hidden" name="major1" value="${major1}">
        <input type="hidden" name="pageIndex" value="${pageIndex}">
        <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12">专业
                <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
                <select name="major" id="major" required="required"
                        class="form-control col-md-7 col-xs-12">
                    <option value="">---请选择---</option>
                    <c:forEach var="maj" items="${majors }">
                        <option value="${maj.major}"
                                <c:if test="${maj.major eq majorInfo}">
                                    selected
                                </c:if>
                        >${maj.major}</option>
                    </c:forEach>
                </select>
            </div>
        </div>
        <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12">班级
                <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
                <select name="classID" id="classname" required="required"
                        class="form-control col-md-7 col-xs-12">
                    <option value="">---请选择---</option>
                    <c:forEach var="cla" items="${cList }">
                        <option value="${cla.classId}"
                                <c:if test="${cla.classId == studentInfo.classId}">
                                    selected
                                </c:if>
                        >${cla.className}</option>
                    </c:forEach>
                </select>
            </div>
        </div>


        <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12">姓名
                <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
                <input type="text" id="name" name="name"
                       data-validate-linked="email" required="required"
                       class="form-control col-md-7 col-xs-12" value="${studentInfo.studentName}">
            </div>
        </div>
        <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12"
            >来自院校 <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
                <input id="fromschool" type="tel" name="fromschool"
                       data-validate-length-range="5,20" required="required"
                       class="optional form-control col-md-7 col-xs-12" value="${studentInfo.fromSchool}">
            </div>
        </div>
        <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">学历(大专/本科)<span
                    class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
                <select name="education" id="education" required="required"
                        class="form-control col-md-7 col-xs-12">
                    <option value="${studentInfo.education}">---请选择---</option>
                    <option value="专科"
                            <c:if test="${studentInfo.education eq '专科'}">
                                selected
                            </c:if>
                    >专科</option>
                    <option value="本科"
                            <c:if test="${studentInfo.education eq '本科'}">
                                selected
                            </c:if>
                    >本科</option>
                </select>
            </div>
        </div>
        <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">登录账号(姓名拼音)<span
                    class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
                <input id="username" class="form-control col-md-7 col-xs-12"
                       data-validate-length-range="6" data-validate-words="2"
                       name="username" required="required" type="text" value="${studentInfo.loginCode}">
            </div>
        </div>
        <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12">登录密码
                <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
                <input type="password" id="userpwd" name="userpwd"
                       required="required" class="form-control col-md-7 col-xs-12" value="${studentInfo.password}">
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-6 col-md-offset-3">
                <input type="submit" value="提交" class="btn btn-primary" />
                <button type="reset" class="btn btn-success">重置</button>
                <a href="chaservlet.do?namec=${namec}&classname=${classname}&major=${major1}&pageIndex=${pageIndex}" id="send" type="button"
                   class="btn btn-success">取消</a>
            </div>
        </div>
    </form>
</div>
<!-- 增加页面结束 -->
<%@ include file="../common/footer.jsp"%>
<%--<script src="${ctx }/statics/localjs/appinfoList.js"></script>--%>
<script src="${ctx }/statics/localjs/StuAdd.js"></script>
<script>
    $(function (){
        $("#major").change(function(){
            var major=$("#major").val();
            if (null!=major&&major!="") {
                $.ajax({
                    type:"POST",//提交方式，默认GET
                    url:"studentAjax.do?operation=class",//提交的服务器地址
                    data:"major="+major,
                    dataType:"json",
                    success:function(data){
                        $("#classname").html("");
                        var options="<option value='' >---请选择---</option>";
                        for(var i=0;i<data.length;i++){
                            options+="<option value='"+data[i].classId+"' >"+data[i].className+"</option>";
                        }
                        $("#classname").html(options);
                    },
                    error:function(){
                        alert('加载二级菜单失败！');
                        location.href="401.jsp"
                    }
                });
            }else{
                $("#classname").html("");
                var options="<option value='' >---请选择---</option>";
                $("#classname").html(options);
            }
        });
    });
</script>